package co.fitstart.coach.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dynamic;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.course.round.CourseRound;
import co.fitstart.entity.user.StudentTargetData;
import co.fitstart.entity.user.User;
import co.fitstart.entity.user.bwh.BwhRecord;
import co.fitstart.entity.user.inbody.InbodyRecord;

/**
 * 
 * @author wangliwang
 *
 */
@Dynamic("hibernate")
public interface RecordDao {

    /**
     * @param user
     * @return
     */
    @Query("FROM InbodyRecord WHERE disabled = false AND user = :user AND recordTime BETWEEN :start AND :end ORDER BY recordTime DESC")
    public List<InbodyRecord> listInbodyRecord(@Variable("user") User user, @Variable("start") String start, @Variable("end") String end);
    
    /**
     * @param user
     * @return
     */
    @Query("FROM BwhRecord WHERE user = :user AND recordTime BETWEEN :start AND :end AND disabled = false ORDER BY recordTime DESC")
    public List<BwhRecord> listBwhRecord(@Variable("user") User user, @Variable("start") String start, @Variable("end") String end);
    
    /**
     * 
     * @param courseRound
     * @return
     */
    @Query("FROM StudentTargetData WHERE courseRound = :courseRound AND disabled=false ORDER BY createTime DESC")
    public List<StudentTargetData> listTargets(@Variable("courseRound") CourseRound courseRound);
    
    /**
     * 
     * @param courseRound
     * @return
     */
    @Query("FROM BwhRecord WHERE disabled = false AND courseRound = :courseRound and week IS NOT NULL")
    public List<BwhRecord> listBwhRecord(@Variable("courseRound") CourseRound courseRound);

    /**
     * 
     * @param courseRound
     * @return
     */
    @Query("FROM StudentTargetData WHERE disabled = false AND courseRound = :courseRound AND targetType IS NOT NULL ORDER BY createTime DESC")
    public StudentTargetData loadStudentTargetData(@Variable("courseRound") CourseRound courseRound);
}
